﻿using MQTTnet.Client;
using System.Text;
using UtilsCache;
using UtilsMQ;
using UtilsMQ.Model;
using UtilsORM.MySqlData;
using UtilsORM;

namespace MqttClient
{
    public class ServiceMqttClient : MqttClientService
    {
        public  ServiceMqttClient()
        {
            _topic = "mq_topic1";
    

        }
        /// <summary>
        /// 收到消息事件
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public override Task _mqttClient_ApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs arg)
        {
            Console.WriteLine($"收到消息事件ApplicationMessageReceivedAsync：客户端ID=【{arg.ClientId}】接收到消息。Topic主题=【{arg.ApplicationMessage.Topic}】 消息=【{Encoding.UTF8.GetString(arg.ApplicationMessage.PayloadSegment)}】 qos等级=【{arg.ApplicationMessage.QualityOfServiceLevel}】");

          
            return Task.CompletedTask;
        }

    }
}
